package test2;

public class PhoneTest {
    public static void main(String[] args) {
        //创建三个对象
        Phone p1 = new Phone("苹果",8999,"白色");
        Phone p2 = new Phone("华为",3999,"蓝色");
        Phone p3 = new Phone("荣耀",4999,"黑色");
        //创建一个数组
        //把对象放在数组中
        Phone [] arr = {p1,p2,p3};
        //先计算三部手机价格总和
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i].getPrice();
        }
        //求平均值
        int avg=sum/arr.length;
        //输出
        System.out.println(avg);

    }
}
